﻿@{
    ViewBag.Title = "修改密码";
    Layout = "~/Views/Shared/_ViewFormPage.cshtml";
}
@model PasswordVM
@section head{
    <script type="text/javascript">
        $(function () {
            $("#btnSave").click(function () {
                changePWD();
            });

            $.shortcut('return', function () {
                changePWD();
            });

            $("#btnCancel").click(function () {
                returnHome();
            });

            $("#OldPassword").focus();

        });

        function returnHome() {
            if (top.window.addTab && $.isFunction(top.window.addTab)) {
                top.window.addTab("homeTab", "主页", "@Url.Action("Welcome", "Home")");
                //.tab.addTabItem({ tabid: "homeTab", text: "主页", url: "@Url.Action("Welcome", "Home")" });
            }
        }

        function changePWD() {
            if ($("form").valid()) {
                $('form').ajaxSubmit(function (callback) {
                    if (callback) {
                        $.messageTip().show("密码修改成功，下次登录时将使用新密码！", 1500, function () {
                            returnHome();
                        });
                    }
                    else {
                        $.messageTip().show("密码修改失败！");
                    }
                });
            }

        }
    </script>
}
<div id="header" class="header">
    <h4>修改密码</h4>
</div>
@using (Html.BeginForm("ChangePassword", "Home", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <div id="detail_forms">
        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                旧密码
            </div>
            <div class="formItem textItem">
                @Html.PasswordFor(model => model.OldPassword, new { @class = "texts", tabindex = "1" })
            </div>
            <div class="formItem msgItem">
                *
            </div>
        </div>
        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                新密码
            </div>
            <div class="formItem textItem">
                @Html.PasswordFor(model => model.NewPassword, new { @class = "texts", tabindex = "2" })
            </div>
            <div class="formItem msgItem">
                *
            </div>
        </div>
        <div class="formsItems clearfix">
            <div class="zhyl_detail_forms_wrapper">
                <div class="formItem labelItem">
                    确认新密码
                </div>
                <div class="formItem textItem">
                    @Html.PasswordFor(model => model.ConfirmPassword, new { @class = "texts", tabindex = "3" })
                </div>
                <div class="formItem msgItem">
                    *
                </div>
            </div>
        </div>
        <div id="btnContainer" class="formsItems clearfix">
            <div class="formItem labelItem">
                &nbsp;
            </div>
            <div class="formItem textItem">
                <a href="javascript:void(0);" id="btnSave">保存</a> <a href='javascript:void(0);'
                    id="btnCancel">取消</a>
            </div>
            <div class="formItem">
            </div>
        </div>
    </div>
}
